package ar.com.quickmart.connectivity;

import java.util.ArrayList;
import java.util.List;

import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;

import com.google.gson.Gson;

import android.util.Log;
import ar.com.quickmart.dto.SimpleXYCompareDto;



public class WebServiceStatistics extends WebServiceBase{

	
	static public SimpleXYCompareDto getAcumPurchasedInMonth(String userName, int month, int year) throws Exception{
		
		// Variables propias del webservice
		String methodName = "getStatisticsAcumPurchasedInMonth";
		String param1 = "userName";
		String param2 = "month";
		String param3 = "year";
		SoapPrimitive callResult;
		//List<SoapObject> result;
	
		// Variables
		SimpleXYCompareDto xy;
		
		// Creo parametro con el id del supermercado
        PropertyInfo userNameParameter = new PropertyInfo();
        userNameParameter.setName(param1);
        userNameParameter.setValue(userName);
        userNameParameter.setType(String.class);
        
        PropertyInfo monthParameter = new PropertyInfo();
        monthParameter.setName(param2);
        monthParameter.setValue(month);
        monthParameter.setType(int.class);
        
        PropertyInfo yearParameter = new PropertyInfo();
        yearParameter.setName(param3);
        yearParameter.setValue(year);
        yearParameter.setType(int.class);
	    
        try {
        	
        	// Obtengo el resultado
        	callResult = (SoapPrimitive) callWebService(methodName, userNameParameter, monthParameter, yearParameter);
        	
        	// Si obtuve la lista
        	if(callResult != null) {
        	
        		
        		String result = callResult.toString();
        		
        		Gson gson = new Gson();
        		
        		xy = gson.fromJson(result, SimpleXYCompareDto.class);

        		
        	}
        	else{
        		xy= null;
        	}
        }
        catch (Exception ex) {
        	ex.printStackTrace();
        	
        	throw ex;
        	
        	
        }
        
        return xy;
	}
}
